package com.gxa.controller;

import com.gxa.common.R;
import com.gxa.common.ResponseData;
import com.gxa.common.State;
import com.gxa.pojo.Params_Son;
import com.gxa.pojo.Resume;
import com.gxa.service.TalentPoolService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller     //修饰整个类，描述Controller的作用
//在  http://localhost:8080/swagger-ui.html  地址中查看下面的效果
@Api(value = "人才库储备",tags = "人才库储备接口API")   //  value：代表代码级描述  tags：代表页面级描述
@RequestMapping(value = "/talentPool/*")   //接口和前端传递数据方式
public class TalentPoolController {
    @Autowired
    private TalentPoolService talentPoolService;


    @RequestMapping(value = "/login" , method = RequestMethod.POST)   //接口和前端传递数据方式
    @ApiOperation(value = "登录接口",notes = "传递电话和密码",httpMethod = "POST", response = ResponseData.class)  //swagger对方法的详细描述
    @ApiImplicitParams({    //限制
            @ApiImplicitParam(name = "re_tel",value = "电话",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "re_password",value = "密码",paramType = "query",dataType = "String",required = true)
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏的请求，接收参数"),
            @ApiResponse(code=405,message="方法不允许，请求方式错误"),
            @ApiResponse(code=500,message="格式错误"),
            @ApiResponse(code=505,message="后台数据库错误")
    })
    @ResponseBody   //响应json数据给前端
    //登录接口
    public ResponseData login(@RequestParam(name = "re_tel") String re_tel, @RequestParam(name = "re_password") String re_password){
        //date里放实体
        Resume resume = new Resume();
        Resume resume2 = new Resume();
        Resume resume3 = new Resume();
        List<Resume> list = new ArrayList<Resume>();
        list.add(resume);
        list.add(resume2);
        list.add(resume3);
        ResponseData r = new ResponseData(200,"请求成功",list,"非常长长长长长长长长长长长长长的字符串");
        return r;
    }

    @RequestMapping(value = "/register" , method = RequestMethod.POST)   //接口和前端传递数据方式
    @ApiOperation(value = "注册接口",notes = "传递简历表对象",httpMethod = "POST", response = R.class)  //swagger对方法的详细描述
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏的请求，接收参数"),
            @ApiResponse(code=405,message="方法不允许，请求方式错误"),
            @ApiResponse(code=500,message="手机已注册"),
            @ApiResponse(code=505,message="后台数据库错误")
    })
    @ResponseBody   //响应json数据给前端
    //注册接口
    public R register(Resume resume){
        R r = new R();
        //判断电话是否已注册
        if("11122223333".equals(resume.getRe_tel())){   //已注册
            r.setCode(500);
            r.setMsg("该手机已经登记过，请勿重复登记");
        }else{
            r.setCode(200);
            r.setMsg("注册成功");
        }
        return r;
    }



    @RequestMapping(value = "/modifyPwd" , method = RequestMethod.POST)   //接口和前端传递数据方式
    @ApiOperation(value = "修改密码接口",notes = "传递这个人的ID、新密码、旧密码",httpMethod = "POST", response = R.class)  //swagger对方法的详细描述
    @ApiImplicitParams({    //限制
            @ApiImplicitParam(name = "resume_id",value = "这个人的ID",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "new_re_password",value = "新密码",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "old_re_password",value = "旧密码(123456)",paramType = "query",dataType = "String",required = true)
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏的请求，接收参数"),
            @ApiResponse(code=405,message="方法不允许，请求方式错误"),
            @ApiResponse(code=500,message="旧密码错误"),
            @ApiResponse(code=505,message="后台数据库错误")
    })
    @ResponseBody   //响应json数据给前端
    //修改密码接口
    public R modifyPwd(@RequestParam(name = "resume_id") Integer resume_id, @RequestParam(name = "new_re_password") String new_re_password, @RequestParam(name = "old_re_password") String old_re_password){
        R r = new R();
        //判断密码是否正确
        if("123456".equals(old_re_password)){ //正确
            r.setCode(200);
            r.setMsg("修改成功");
        }else{
            r.setCode(500);
            r.setMsg("旧密码错误");
        }
        return r;
    }

    @RequestMapping(value = "/informationBasic" , method = RequestMethod.POST)   //接口和前端传递数据方式
    @ApiOperation(value = "基本资料接口",notes = "传递简历表对象",httpMethod = "POST", response = R.class)  //swagger对方法的详细描述
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏的请求，接收参数"),
            @ApiResponse(code=405,message="方法不允许，请求方式错误"),
            @ApiResponse(code=505,message="后台数据库错误")
    })
    @ResponseBody   //响应json数据给前端
    //基本资料接口
    public R informationBasic (Resume resume){
        R r = new R();
        r.setCode(200);
        r.setMsg("注册成功");
        return r;
    }

    @RequestMapping(value = "/informationDetails" , method = RequestMethod.POST)   //接口和前端传递数据方式
    @ApiOperation(value = "详细资料接口",notes = "传递简历表对象",httpMethod = "POST", response = R.class)  //swagger对方法的详细描述
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏的请求，接收参数"),
            @ApiResponse(code=405,message="方法不允许，请求方式错误"),
            @ApiResponse(code=505,message="后台数据库错误")
    })
    @ResponseBody   //响应json数据给前端
    //详细资料接口
    public R informationDetails (Resume resume){
        R r = new R();
        r.setCode(200);
        r.setMsg("保存成功");
        return r;
    }

    @RequestMapping(value = "/informationFile" , method = RequestMethod.POST)   //接口和前端传递数据方式
    @ApiOperation(value = "文件资料接口",notes = "传递简历表对象",httpMethod = "POST", response = R.class)  //swagger对方法的详细描述
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏的请求，接收参数"),
            @ApiResponse(code=405,message="方法不允许，请求方式错误"),
            @ApiResponse(code=505,message="后台数据库错误")
    })
    @ResponseBody   //响应json数据给前端
    //文件资料接口
    public R informationFile (Resume resume){
        R r = new R();
        r.setCode(200);
        r.setMsg("保存成功");
        return r;
    }



    @RequestMapping(value = "/queryNation" , method = RequestMethod.GET)   //接口和前端传递数据方式
    @ApiOperation(value = "查询民族接口",notes = "不传递值",httpMethod = "GET", response = R.class)  //swagger对方法的详细描述
    @ResponseBody   //响应json数据给前端
    //查询民族接口
    public R queryNation(){
        Params_Son params_Son = new Params_Son();
        Params_Son params_Son2 = new Params_Son();
        Params_Son params_Son3 = new Params_Son();
        List<Params_Son> list = new ArrayList<Params_Son>();
        list.add(params_Son);
        list.add(params_Son2);
        list.add(params_Son3);

        R r = new R(200,"请求成功",list);
        return r;
    }

    @RequestMapping(value = "/queryDuties" , method = RequestMethod.GET)   //接口和前端传递数据方式
    @ApiOperation(value = "查询职务接口",notes = "不传递值",httpMethod = "GET", response = R.class)  //swagger对方法的详细描述
    @ResponseBody   //响应json数据给前端
    //查询职务接口
    public R queryDuties(){
        Params_Son params_Son = new Params_Son();
        Params_Son params_Son2 = new Params_Son();
        Params_Son params_Son3 = new Params_Son();
        List<Params_Son> list = new ArrayList<Params_Son>();
        list.add(params_Son);
        list.add(params_Son2);
        list.add(params_Son3);

        R r = new R(200,"请求成功",list);
        return r;
    }

    @RequestMapping(value = "/queryEducation" , method = RequestMethod.GET)   //接口和前端传递数据方式
    @ApiOperation(value = "查询学历接口",notes = "不传递值",httpMethod = "GET", response = R.class)  //swagger对方法的详细描述
    @ResponseBody   //响应json数据给前端
    //查询学历接口
    public R queryEducation(){
        Params_Son params_Son = new Params_Son();
        Params_Son params_Son2 = new Params_Son();
        Params_Son params_Son3 = new Params_Son();
        List<Params_Son> list = new ArrayList<Params_Son>();
        list.add(params_Son);
        list.add(params_Son2);
        list.add(params_Son3);

        R r = new R(200,"请求成功",list);
        return r;
    }

}
